﻿using System.Collections.Generic;
using TL_Cloud.Core.Interfaces;

namespace TL_Cloud.Core.Services
{
    /// <summary>
    /// 两个之间的属性映射
    /// </summary>
    /// <typeparam name="TSource"></typeparam>
    /// <typeparam name="TDestination"></typeparam>
    public abstract class PropertyMapping<TSource, TDestination> : IPropertyMapping 
        where TDestination : IEntity
    {
        /// <summary>
        /// source 和 目标上的对应关系
        ///  source上的一个属性可以对应的目标上的多个属性
        /// </summary>
        public Dictionary<string, List<MappedProperty>> MappingDictionary { get; }
                        

        protected PropertyMapping(Dictionary<string, List<MappedProperty>> mappingDictionary)
        {
            MappingDictionary = mappingDictionary;
            MappingDictionary[nameof(IEntity.CreateDate)] = new List<MappedProperty>
            {
                new MappedProperty { Name = nameof(IEntity.CreateDate), Revert = false}
            };
        }
    }
}
